#include "FileManager.hpp"
#ifdef RENDERFISH_PLATFORM_IS_WINDOWS
#include <experimental\filesystem>
namespace fs = std::experimental::filesystem;
#endif

string FileManager::mWorkingDir;

string FileManager::currentPath() {
#ifdef RENDERFISH_PLATFORM_IS_WINDOWS
	std::cout << "current path is " << fs::current_path() << "\n";
	return fs::current_path().string();
#else
	//return "/Users/yushroom/program/graphics/RayTracer";
	return ".";
#endif
}

//string FileManager::stem(const string path) {
//	return fs::path(path).stem().string();
//}

string FileManager::parentPath(const string path) {
#ifdef RENDERFISH_PLATFORM_IS_WINDOWS
	return fs::path(path).parent_path().string();
	//return (fs::path(path) / "..").string();
#else
	auto pos = path.find_last_of('/');
	Assert(pos != string::npos && pos != path.size() - 1);
	return path.substr(0, pos);
#endif
}

string FileManager::getWorkingDir() {
	return mWorkingDir;
}

void FileManager::setWorkingDir(const string& path) {
	mWorkingDir = path;
}